<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="org.example.pojo.Product" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>编辑商品 - MobileWorld</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f8f9fa;
        }
        header {
            background-color: #0078D7;
            color: white;
            text-align: center;
            padding: 1.5rem;
            animation: fadeInDown 0.8s ease-out;
        }
        header h1 {
            margin: 0;
        }
        .container {
            max-width: 400px;
            margin: 50px auto;
            padding: 2rem;
            background: #ffffff;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
            animation: fadeInUp 0.8s ease-out;
        }
        h2 {
            color: #0078D7;
            text-align: center;
            margin-bottom: 1rem;
        }
        form {
            display: flex;
            flex-direction: column;
            gap: 1rem;
        }
        label {
            font-weight: bold;
        }
        input[type="text"], input[type="number"], button {
            padding: 0.8rem;
            font-size: 1rem;
            border: 1px solid #ddd;
            border-radius: 5px;
            outline: none;
        }
        button {
            background-color: #0078D7;
            color: white;
            cursor: pointer;
            border: none;
            border-radius: 5px;
            padding: 0.8rem;
            font-size: 1rem;
            transition: background-color 0.3s ease;
        }
        button:hover {
            background-color: #005bb5;
        }
        .back-link, .home-link {
            text-align: center;
            margin-top: 1rem;
        }
        .back-link a, .home-link a {
            text-decoration: none;
            color: #0078D7;
            font-weight: bold;
        }
        .back-link a:hover, .home-link a:hover {
            text-decoration: underline;
        }
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        @keyframes fadeInDown {
            from {
                opacity: 0;
                transform: translateY(-20px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
    </style>
</head>
<body>
<header>
    <h1>编辑商品</h1>
</header>
<div class="container">
    <h2>修改商品信息</h2>
    <form action="products" method="post">
        <input type="hidden" name="action" value="update">
        <!-- 使用 EL 表达式引用传递过来的 product 对象 -->
        <input type="hidden" name="id" value="${product.id}">

        <label for="name">商品名称：</label>
        <input type="text" id="name" name="name" value="${product.name}" placeholder="请输入商品名称" required>

        <label for="price">价格：</label>
        <input type="number" step="0.01" id="price" name="price" value="${product.price}" placeholder="请输入商品价格" required>

        <label for="stock">库存：</label>
        <input type="number" id="stock" name="stock" value="${product.stock}" placeholder="请输入商品库存" required>

        <button type="submit">保存修改</button>
    </form>
    <div class="back-link">
        <a href="products">返回商品页面</a>
    </div>
    <div class="home-link">
        <a href="index.jsp">返回主页</a>
    </div>
</div>
</body>
</html>
